package com.pinganfu.tesla.iwallet.tab;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pinganfu.tesla.iwallet.BalanceActivity;
import com.pinganfu.tesla.iwallet.CardListActivity;
import com.pinganfu.tesla.iwallet.MyprofileActivity;
import com.pinganfu.tesla.iwallet.R;
import com.pinganfu.tesla.iwallet.session.SessionManager;
import com.pinganfu.tesla.iwallet.util.TeslaUtil;

public class TabFortuneActivity extends Activity implements OnClickListener {

	private TextView tvRealName = null;
	private TextView tvMobileNo = null;
	private SessionManager mSessionMgr = SessionManager.getInstance();

	private TextView tvBalance = null;
	private TextView tvCardCount = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tab_fortune);

		tvRealName = (TextView) findViewById(R.id.tv_real_name);
		tvMobileNo = (TextView) findViewById(R.id.tv_mobile_no);

		tvRealName.setText(mSessionMgr.getUserPref().getCertName());
		tvMobileNo.setText(mSessionMgr.getUserPref().getMobileNo());

		tvBalance = (TextView) findViewById(R.id.tv_balance);
		tvCardCount = (TextView) findViewById(R.id.tv_card_count);

		RelativeLayout layoutMyprofile = (RelativeLayout) findViewById(R.id.layout_myprofile);
		layoutMyprofile.setOnClickListener(this);

		RelativeLayout layoutBalance = (RelativeLayout) findViewById(R.id.layout_balance);
		layoutBalance.setOnClickListener(this);

		RelativeLayout layoutMyCards = (RelativeLayout) findViewById(R.id.layout_my_cards);
		layoutMyCards.setOnClickListener(this);

		// TODO debug
		tvBalance.setText("10000.89");
		tvCardCount.setText("4");
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
			case R.id.layout_balance :
				TeslaUtil.gotoActivity(this, BalanceActivity.class);
				break;
			case R.id.layout_my_cards :
				TeslaUtil.gotoActivity(this, CardListActivity.class);
				break;
			case R.id.layout_myprofile :
				TeslaUtil.gotoActivity(this, MyprofileActivity.class);
				break;
		}
	}
}
